//
//  KDWorkingReportCell.m
//  WangJingApp
//
//  Created by 魏强 on 17/11/3.
//  Copyright © 2017年 KDTech. All rights reserved.
//

#import "KDWorkingReportCell.h"
#import "NSDate+Extension.h"
@interface KDWorkingReportCell ()
@property (weak, nonatomic) IBOutlet UILabel *titleLb;
@property (weak, nonatomic) IBOutlet UIButton *fstStar;
@property (weak, nonatomic) IBOutlet UIButton *scndStar;
@property (weak, nonatomic) IBOutlet UIButton *thirdStar;
@property (weak, nonatomic) IBOutlet UILabel *timeLb;
@property (weak, nonatomic) IBOutlet UIImageView *todayIv;

@end
@implementation KDWorkingReportCell
+ (instancetype)cellWithTableView:(UITableView *)tableView{
    static NSString *cellId =@"KDWorkingReportCell";
    
    
    KDWorkingReportCell *cell =[tableView dequeueReusableCellWithIdentifier:cellId];
    cell.backgroundColor = BackGroundColor;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    //    [cell.reportBtn setImage:[UIImage imageNamed:@"已上报"] forState:UIControlStateDisabled];
    //监听收藏状态改变之后的通知
    
    
    return cell;
}

- (void)setModel:(KDWorkingReportModel *)model{
    _model = model;
    switch (model.star) {
        case 0:
            self.fstStar.selected = NO;
            self.scndStar.selected = NO;
            self.thirdStar.selected = NO;
            break;
        case 1:
            self.fstStar.selected = YES;
            self.scndStar.selected = NO;
            self.thirdStar.selected = NO;
            break;
        case 2:
            self.fstStar.selected = YES;
            self.scndStar.selected = YES;
            self.thirdStar.selected = NO;
            break;
        case 3:
            self.fstStar.selected = YES;
            self.scndStar.selected = YES;
            self.thirdStar.selected = YES;
            break;
            
        default:
            break;
    }
    self.titleLb.text = model.title;
    NSDateFormatter *fmt = [[NSDateFormatter alloc]init];
    fmt.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];
    fmt.dateFormat = @"YYYY-MM-dd HH:mm:ss.S";
    NSDate *date = [fmt dateFromString:model.update_dt];
    if ( date.isToday) {
        self.todayIv.hidden = NO;
        fmt.dateFormat = @"HH:mm";
    }else{
        self.todayIv.hidden = YES;
         fmt.dateFormat = @"YYYY-MM-dd HH:mm";
    }
    self.timeLb.text = [fmt stringFromDate:date];
    
   
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
